package com.ss.dcspeed;

import android.content.Context;
import android.database.DatabaseUtils;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class CameraLocationSQLiteHelper extends SQLiteOpenHelper {

	private final static String DATABASE_NAME = "DC_CAMERAS";
	private final static String LOCATIONS_TABLE = "LOCATIONS";
	private final static String NAME_COLUMN = "NAME";
	private final static String LAT_COLUMN = "LAT";
	private final static String LONG_COLUMN = "LONG";
	private final static int DATABASE_VERSION = 1;
	private final static String TABLE_CREATE_SQL = "CREATE TABLE "+LOCATIONS_TABLE+" (" +
			NAME_COLUMN + " TEXT," + 
			LAT_COLUMN + " REAL," +
			LONG_COLUMN + " REAL," +
			")";

	SQLiteDatabase db;
	
	public CameraLocationSQLiteHelper(Context context){
		super(context, DATABASE_NAME, null, DATABASE_VERSION);
	}

	@Override
	public void onCreate(SQLiteDatabase arg0) {
		db = getWritableDatabase();
		db.execSQL(TABLE_CREATE_SQL);

		DatabaseUtils.InsertHelper ih = new DatabaseUtils.InsertHelper(db, DATABASE_NAME);
		ih.prepareForInsert();
		ih.bind(ih.getColumnIndex(NAME_COLUMN), "WHITE_HOUSE");
		ih.bind(ih.getColumnIndex(LAT_COLUMN), 38.898748);
		ih.bind(ih.getColumnIndex(LONG_COLUMN), -77.037684);
		ih.execute();
		ih.close();
	
	}

	@Override
	public void onUpgrade(SQLiteDatabase arg0, int arg1, int arg2) {
		// TODO Auto-generated method stub

	}

}
